package com.mars.module.app.controller;


import com.mars.common.enums.BusinessType;
import com.mars.common.response.PageInfo;
import com.mars.common.result.R;
import com.mars.common.util.ExcelUtils;
import com.mars.framework.annotation.Log;
import com.mars.framework.annotation.RateLimiter;
import com.mars.module.admin.entity.ApCart;
import com.mars.module.admin.entity.ApCollect;
import com.mars.module.admin.entity.ApCookbook;
import com.mars.module.admin.request.ApCartRequest;
import com.mars.module.admin.request.ApCollectRequest;
import com.mars.module.admin.service.IApCartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * 菜篮子控制层
 *
 * @author mars
 * @date 2024-03-02
 */
@Slf4j
@AllArgsConstructor
@RestController
@Api(value = "菜篮子接口管理", tags = "菜篮子接口管理")
@RequestMapping("/app/apCart")
public class AppCartController {

    private final IApCartService iApCartService;


    /**
     * 加入菜篮子
     */
    @ApiOperation(value = "加入菜篮子")
    @PostMapping("/join")
    public R<Void> collect(@RequestBody ApCartRequest apCartRequest) {
        iApCartService.join(apCartRequest);
        return R.success();
    }


    /**
     * 菜篮子列表
     */
    @ApiOperation(value = "菜篮子列表")
    @PostMapping("/list")
    public R<List<ApCookbook>> list(@RequestBody ApCartRequest apCartRequest) {
        return R.success(iApCartService.cartList(apCartRequest));
    }
}
